2.5.11.3 Logical Operators
Table 2.3 shows the logical operators which also give Boolean as the
output, as follows:
OPERATOR
DENOTATION
DESCRIPTION
Logical AND
&&
Returns true if both conditions are true, and
false if one or both conditions are false
Logical OR
||
Returns true if one or both conditions are true,
and false when both are false
Logical NOT
!
Returns true if the condition is not satisfied,
else false
Table 2.3: Logical Operators
The following is a sample program:
// SPDX-License-Identifier: Some Identifier
pragma solidity ^0.8.10;
contract LogicalContract {
uint a = 10;
uint b = 2;
function logicalAnd() public view returns(bool) {
return a >= b && a > b;
}
function logicalOr() public view returns(bool) {
return a == b || a > b;
}
function logicalNot() public pure returns(bool) {
bool someBool = true;
return !someBool;
}
}
2.5.11.4 Bitwise Operator